package com.uestc.soft.controller;

import com.uestc.soft.pojo.Loophole;
import com.uestc.soft.service.LoopholeService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
public class LoopholeController {

    @Resource
    private LoopholeService loopholeService;


    @RequestMapping("/loophole/insert")
    public Map<String, Object> insert(@RequestBody Loophole loophole) {
        return loopholeService.insert(loophole);
    }

    @RequestMapping("/loophole/deleteById")
    public Map<String, Object> deleteById(@RequestParam Integer id) {
        return loopholeService.deleteById(id);
    }

    @RequestMapping("/loophole/updateNmuber")
    public Map<String, Object> updateAge(@RequestParam("id") Integer id,
                                         @RequestParam("number") Integer number) {
        return loopholeService.updateLevelAndNumber(id, number );
    }

    @RequestMapping("/loophole/selectByPage")
    public Map<String, Object> selectByPage(@RequestParam int page,
                                            @RequestParam int limit,
                                            String level,
                                            String number) {
        return loopholeService.selectByPage(page, limit, level, number);
    }
}
